<template>
  <!-- 上传厂家证照的表格modal -->
  <div>
    <basic-modal 
        :modalOpt="modal" 
        :buttonText="['','关闭']"
        @onMakeSure="onPush"
        @closeModal="closeModal" 
        :footer="footer" 
        >
      <template #cusBtn>
      </template>
      <template>
        <batch-operat-btn v-if="editable" :isView="false" :addData="true" @onAddData="onAddData">
          <template #cusBtn> </template>
        </batch-operat-btn>
        <a-list-info :infoDatas="infoDatas" span="12" />
      </template>
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '@/views/app/biz/common/basicModal'
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import batchOperatBtn from '@/views/app/biz/common/batchOperatBtn'

import {
  getInfoByPid,
} from './PlatformData'

export default {
  components: {
    basicModal,
    aListTable,
    batchOperatBtn,
    aListInfo
  },
  data() {
    return {
      footer:undefined,
      editable:false,
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '审核证照',
        modalWidth: '80vw',
      },
      infoDatas:[
        { title: '数据有效区域(国、省、市、县、院)', id: 'areaUse',  value:''},
        { title: '商品自编码', id: 'code',  value:''},
        { title: '品名', id: 'productNameZh',  value:''},
        { title: '英文名称', id: 'productNameEn',  value:''},
        { title: '通用名(商品名)', id: 'commonName',  value:''},
        { title: '一级分类（学科、品类）', id: 'first',  value:''},
        { title: '二级分类（用途、品目）', id: 'second',  value:''},
        { title: '三级分类（部位、功能、品种）', id: 'third',  value:''},
        { title: '规格（特征、参数）', id: 'spec',  value:''},
        { title: '型号(剂型)', id: 'model',  value:''},
        { title: '医保代码', id: 'medicareCode', value:''},
        { title: '描述', id: 'disc',  value:''},
        { title: '品牌', id: 'brand',  value:''},
        { title: '上市许可持有企业社会编码', id: 'mahCode',  value:''},
        { title: '上市许可持有企业中文名', id: 'mahZh',  value:''},
        { title: '上市许可持有企业英文名', id: 'mahEn',  value:''},
        { title: '生产企业社会编码', id: 'manufacturerCode',  value:''},
        { title: '生产企业中文名称', id: 'manufacturerZh',  value:''},
        { title: '生产企业英文名称', id: 'manufacturerEn',  value:''},
        { title: '产地', id: 'origin',  value:''},
        { title: '产品类别(字典medicalCategory)', id: 'category',  value:''},
        { title: '计量单位', id: 'measurement',  value:''},
        { title: '药品本位码', id: 'sdc',  value:''},
        { title: '当前批准类型(字典medicalApprovalType)', id: 'approvalType',  value:''},
        { title: '当前注册证号/注册证号', id: 'approvalNum',  value:''},
        { title: '当前有效期始', id: 'approvalDate',  value:''},
        { title: '当前有效期止', id: 'validDate',  value:''},
        { title: '状态(字典medicalProdState)', id: 'state',  value:''},
        { title: '结算方式', id: 'settlement',  value:''},
        { title: '阳采编码', id: 'acquisitionCode',  value:''},
      ],
      listdata: [],
      listKey: 0,
      pid: '',
      zzPid:'',
      sysSeq: 0,
      loadings: false,
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // // 弹出模态框
    showModal(val,record) {
      this.pid = val.pid
      this.record=record
      this.modal.modalVisible = true
      this.modal.modalTitle = '查看详情'
      this.getSBypid(val)
      // this.getZZImgBypid(val2)
      
    },
    // 关闭模态详细框
    closeModal() {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    closeModal2() {
      this.modal.modalVisible = false
      this.$emit('ok')
    },
    //
    onAddData() {
      this.$refs.addSellerLicChildModal.addModal(this.pid)
    },

    // 推送
    onPush() {
      this.showConfirm(this.record)
    },
    // 保存详细信息
    showConfirm(val) {
      const that = this;
      this.$confirm({
        title: '是否确认推送？',
        content: '推送成功后请提醒客户审核！',
        onOk() {
          return new Promise((resolve, reject) => {
            resolve(pushInfo(val))
          }).then((res)=>{
            if (res && res.code && res.code === 'C1' && res.data) {
              that.$message.success({ content: '推送成功', duration: 2 })
              that.handleModalSaveOk()
            } else {
              that.$message.error({ content:res.code +'：'+res.message, duration: 2 })
            }
          })
          .catch(() =>{
            that.$message.error({ content:"请求出错", duration: 2 })
          });
        },
        onCancel() {},
      });
    },
    // 得到初始化信息
    async getSBypid(val) {
      let res = await getInfoByPid(val)
      if (res && res.code && res.code === 'C1') {
        this.sysSeq = res.data.sysSeq
        for (const key in res.data) {
            for (const item of this.infoDatas) {
                if(key==item.id){
                    item.value=res.data[key]
                }
            }
        }
      }
    },
    // 得到初始化证照图片信息
    // async getZZImgBypid(val2) {
    //   this.loading=true
    //   let pa = {
    //     zhengZhaoPid: val2,
    //   }
    //   let res = await getZZImgByzzpid(pa)
    //   if (res && res.code && res.code === 'C1' && res.data) {
    //     this.listdata = res.data
    //     this.loading=false
    //   }
    //   console.log(res)
    // },
  },
}
</script>

<style>
.recordBox {
  width: 100%;
  min-height: 80px;
}
</style>